package com.it.emall.service.impl;

import com.it.emall.domain.AdminUser;
import com.it.emall.domain.Comments;
import com.it.emall.mapper.UserMapper;
import com.it.emall.service.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 后台用户Service实现
 */
@Service
public class AdminUserServiceImpl implements AdminUserService {

    @Autowired//把usermapper类型的对象自动注入进来
    private UserMapper userMapper;

    @Override
    public AdminUser login(String username) {
        return userMapper.selectUsername(username);
    }

    @Override
    public AdminUser selectUserById(Integer id) {
        return userMapper.selectUserById(id);
    }


    /**
     * 后台
     * @return
     */

    @Override
    public List<AdminUser> getAllManageUsers() {
        return userMapper.findManageAllUsers();
    }

    @Override
    public int deleteManageUserById(Integer userId) {
        return userMapper.deleteManageUserById(userId);
    }

    @Override
    public int updateManageUser(Integer userId, AdminUser adminUser) {
        adminUser.setUserId(userId); // 确保更新的是对应ID的用户
        return userMapper.updateManageUser(adminUser);

    }

    @Override
    public List<AdminUser> searchManageUsers(String username, String email, Integer age, String gender) {
         return userMapper.searchManageUsers(username, email, age, gender);
    }

    @Override
    public AdminUser getManageUserById(Integer userId) {
        return userMapper.getManageUserById(userId);
    }


}
